# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=findsploit
pkgver=87.3e61d8d
pkgrel=1
pkgdesc='Find exploits in local and online databases instantly.'
groups=('blackarch' 'blackarch-automation' 'blackarch-exploitation')
arch=('any')
url='https://github.com/1N3/findsploit'
license=('custom:unknown')
depends=('bash' 'metasploit' 'firefox' 'exploitdb')
makedepends=('git')
source=("$pkgname::git+https://github.com/1N3/Findsploit.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  sed -i 's|/pentest/|/usr/share/|' copysploit
}

package() {
  cd $pkgname

  _tools="compilesploit copysploit findsploit"

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md

  rm README.md

  cp -a * "$pkgdir/usr/share/$pkgname/"

  for t in $_tools ; do
    cat > "$pkgdir/usr/bin/$t" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec bash $t "\$@"
EOF
    chmod +x "$pkgdir/usr/bin/$t"
  done
}

